﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace lcps.Web
{
    public partial class Welcome : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Bind();
            }
        }

        private void Bind()
        {
            lcps.BLL.article ab = new BLL.article();

            #region 物资供应管理规章制度

            DataSet ds = ab.GetList(" contentType='1' ",16);

            if (ds.Tables[0].Rows.Count > 0)
            {
                string gzzdl = "<ul>";
                string gzzdr = "<ul>";

               
                if (ds.Tables[0].Rows.Count > 8)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        string time = Convert.ToDateTime(ds.Tables[0].Rows[i]["pubtime"].ToString()).ToShortDateString();
                        string title = this.GetString(ds.Tables[0].Rows[i]["title"].ToString(), 20);

                        gzzdl += "<li>";
                        gzzdl += "<span class='art_right'>" + time + "</span>";
                        gzzdl += "<a href='ShowArticle.aspx?id=" + ds.Tables[0].Rows[i]["id"] + "&type=1' target='_blank'>" + title + "</a>";
                        gzzdl += "</li>";

                    }


                    for (int j = 8; j < ds.Tables[0].Rows.Count; j++)
                    {
                        string time = Convert.ToDateTime(ds.Tables[0].Rows[j]["pubtime"].ToString()).ToShortDateString();
                        string title = this.GetString(ds.Tables[0].Rows[j]["title"].ToString(),20);


                        gzzdr += "<li>";
                        gzzdr += "<span class='art_right'>" + time + "</span>";
                        gzzdr += "<a href='ShowArticle.aspx?id=" + ds.Tables[0].Rows[j]["id"] + "&type=1' target='_blank'>" + title + "</a>";
                        gzzdr += "</li>";
                    }
                }
                else
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        string time = Convert.ToDateTime(ds.Tables[0].Rows[i]["pubtime"].ToString()).ToShortDateString();
                        string title = this.GetString(ds.Tables[0].Rows[i]["title"].ToString(), 20);

                        gzzdl += "<li>";
                        gzzdl += "<span class='art_right'>" + time + "</span>";
                        gzzdl += "<a href='ShowArticle.aspx?id=" + ds.Tables[0].Rows[i]["id"] + "&type=1' target='_blank'>" + title + "</a>";
                        gzzdl += "</li>";

                    }

                }


                gzzdl += "</ul>";
                gzzdr += "</ul>";

                this.ltr_gzzdl.Text = gzzdl;
                this.ltr_gzzdr.Text = gzzdr;
            }

            
            #endregion

            #region 班组建设
            DataSet ds2 = ab.GetList(" contentType='2' ", 8);

            if (ds2.Tables[0].Rows.Count > 0)
            {
                string gzzdl2 = "<ul>";
                string gzzdr2 = "<ul>";

                

                if (ds2.Tables[0].Rows.Count > 4)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        string time = Convert.ToDateTime(ds2.Tables[0].Rows[i]["pubtime"].ToString()).ToShortDateString();
                        string title = this.GetString(ds2.Tables[0].Rows[i]["title"].ToString(), 20);

                        gzzdl2 += "<li>";
                        gzzdl2 += "<span class='art_right'>" + time + "</span>";
                        gzzdl2 += "<a href='ShowArticle.aspx?id=" + ds2.Tables[0].Rows[i]["id"] + "&type=2' target='_blank'>" + title + "</a>";
                        gzzdl2 += "</li>";

                    }
                    for (int j = 4; j < ds2.Tables[0].Rows.Count; j++)
                    {
                        string time = Convert.ToDateTime(ds2.Tables[0].Rows[j]["pubtime"].ToString()).ToShortDateString();
                        string title = this.GetString(ds2.Tables[0].Rows[j]["title"].ToString(), 20);


                        gzzdr2 += "<li>";
                        gzzdr2 += "<span class='art_right'>" + time + "</span>";
                        gzzdr2 += "<a href='ShowArticle.aspx?id=" + ds2.Tables[0].Rows[j]["id"] + "&type=2' target='_blank'>" + title + "</a>";
                        gzzdr2 += "</li>";
                    }
                }
                else
                {
                    for (int i = 0; i < ds2.Tables[0].Rows.Count; i++)
                    {
                        string time = Convert.ToDateTime(ds2.Tables[0].Rows[i]["pubtime"].ToString()).ToShortDateString();
                        string title = this.GetString(ds2.Tables[0].Rows[i]["title"].ToString(), 20);

                        gzzdl2 += "<li>";
                        gzzdl2 += "<span class='art_right'>" + time + "</span>";
                        gzzdl2 += "<a href='ShowArticle.aspx?id=" + ds2.Tables[0].Rows[i]["id"] + "&type=2' target='_blank'>" + title + "</a>";
                        gzzdl2 += "</li>";

                    }
                }


                gzzdl2 += "</ul>";
                gzzdr2 += "</ul>";

                this.ltr_bzl.Text = gzzdl2;
                this.ltr_bzr.Text = gzzdr2;
            }

            
            #endregion

            #region 管理创新
            DataSet ds3 = ab.GetList(" contentType='3' ", 16);

            if (ds3.Tables[0].Rows.Count > 0)
            {
                string gzzdl3 = "<ul>";
                string gzzdr3 = "<ul>";

              

                if (ds3.Tables[0].Rows.Count > 8)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        string time = Convert.ToDateTime(ds3.Tables[0].Rows[i]["pubtime"].ToString()).ToShortDateString();
                        string title = this.GetString(ds3.Tables[0].Rows[i]["title"].ToString(), 20);

                        gzzdl3 += "<li>";
                        gzzdl3 += "<span class='art_right'>" + time + "</span>";
                        gzzdl3 += "<a href='ShowArticle.aspx?id=" + ds3.Tables[0].Rows[i]["id"] + "&type=3' target='_blank'>" + title + "</a>";
                        gzzdl3 += "</li>";

                    }
                    for (int j = 8; j < ds3.Tables[0].Rows.Count; j++)
                    {
                        string time = Convert.ToDateTime(ds3.Tables[0].Rows[j]["pubtime"].ToString()).ToShortDateString();
                        string title = this.GetString(ds3.Tables[0].Rows[j]["title"].ToString(), 20);


                        gzzdr3 += "<li>";
                        gzzdr3 += "<span class='art_right'>" + time + "</span>";
                        gzzdr3 += "<a href='ShowArticle.aspx?id=" + ds3.Tables[0].Rows[j]["id"] + "&type=3' target='_blank'>" + title + "</a>";
                        gzzdr3 += "</li>";
                    }
                }
                else
                {
                    for (int i = 0; i < ds3.Tables[0].Rows.Count; i++)
                    {
                        string time = Convert.ToDateTime(ds3.Tables[0].Rows[i]["pubtime"].ToString()).ToShortDateString();
                        string title = this.GetString(ds3.Tables[0].Rows[i]["title"].ToString(), 20);

                        gzzdl3 += "<li>";
                        gzzdl3 += "<span class='art_right'>" + time + "</span>";
                        gzzdl3 += "<a href='ShowArticle.aspx?id=" + ds3.Tables[0].Rows[i]["id"] + "&type=3' target='_blank'>" + title + "</a>";
                        gzzdl3 += "</li>";

                    }
                }


                gzzdl3 += "</ul>";
                gzzdr3 += "</ul>";

                this.ltr_gll.Text = gzzdl3;
                this.ltr_glr.Text = gzzdr3;
            }

           
            #endregion
        }
        private string GetString(string str, int length)
        {
            string re = str;

            if (str.Length > length)
            {
                re = str.Substring(0,length)+"...";
            }

            return re;
        }
    }
}